name: CI/CD Pipeline
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 14
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Deploy to Heroku
run: |
heroku login -i
heroku git:remote -a your-heroku-app-name
git push heroku main
- name: Notify on Slack
uses: rtCamp/action-slack-notify@v2
with:
slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
channel: your-slack-channel
message: 'Deployment to production is complete.'
notify:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Notify on Success
if: failure()
run: echo "Deployment failed" && exit 1
- name: Notify